using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BW.WMS.Infrastructure.Services
{
    public interface IRedisCacheService
    {
        /// <summary>
        /// 设置字符串缓存
        /// </summary>
        Task<bool> SetStringAsync(string key, string value, TimeSpan? expiry = null);

        /// <summary>
        /// 获取字符串缓存
        /// </summary>
        Task<string?> GetStringAsync(string key);

        /// <summary>
        /// 设置对象缓存
        /// </summary>
        Task<bool> SetAsync<T>(string key, T value, TimeSpan? expiry = null);

        /// <summary>
        /// 获取对象缓存
        /// </summary>
        Task<T?> GetAsync<T>(string key);

        /// <summary>
        /// 删除缓存
        /// </summary>
        Task<bool> DeleteAsync(string key);

        /// <summary>
        /// 批量删除缓存
        /// </summary>
        Task<long> DeleteAsync(IEnumerable<string> keys);

        /// <summary>
        /// 检查键是否存在
        /// </summary>
        Task<bool> ExistsAsync(string key);

        /// <summary>
        /// 设置过期时间
        /// </summary>
        Task<bool> ExpireAsync(string key, TimeSpan expiry);

        /// <summary>
        /// 获取剩余过期时间
        /// </summary>
        Task<TimeSpan?> GetExpireAsync(string key);

        /// <summary>
        /// 哈希表操作 - 设置哈希字段
        /// </summary>
        Task<bool> HashSetAsync(string key, string field, string value);

        /// <summary>
        /// 哈希表操作 - 获取哈希字段
        /// </summary>
        Task<string?> HashGetAsync(string key, string field);

        /// <summary>
        /// 哈希表操作 - 删除哈希字段
        /// </summary>
        Task<bool> HashDeleteAsync(string key, string field);

        /// <summary>
        /// 列表操作 - 左推入
        /// </summary>
        Task<long> ListLeftPushAsync(string key, string value);

        /// <summary>
        /// 列表操作 - 右推入
        /// </summary>
        Task<long> ListRightPushAsync(string key, string value);

        /// <summary>
        /// 列表操作 - 左弹出
        /// </summary>
        Task<string?> ListLeftPopAsync(string key);

        /// <summary>
        /// 列表操作 - 右弹出
        /// </summary>
        Task<string?> ListRightPopAsync(string key);

        /// <summary>
        /// 列表操作 - 获取列表长度
        /// </summary>
        Task<long> ListLengthAsync(string key);
    }
}